<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
<script>
var str = "width=device-width";
//start(start,end)包括初始，不包含结束，可以有负数
console.log(str.slice(6,12));//[start,end]
console.log(str.slice(6,-2));//[start,end]

// substring(start,end)不能有负数
console.log(str.substring(5,7));
console.log(str.substring(5,-7));//负数不起作用，结果是从头开始截取长度为5的字符串

// substr(start,length)
console.log(str.substr(5,10));
console.log(str.substr(5));

</script>
</body>
</html>